#ifndef _MT5_PATHFINDING_H_
#define _MT5_PATHFINDING_H_

#include "mat_define.h"

#include <vector>

class MATPathFinding
{
public:

	struct	Tile
	{
		int		m_X;
		int		m_Y;
		int		m_G;
		int		m_H;
		Tile*	m_pParent;
	};

	MATPathFinding();
	
	
	 void							DoPathFinding( int StartY, int StartX, int EndY, int EndX);
	 bool							IsFound()const { return m_IsFound; };
	 const std::vector<Tile*>&		GetPath() const { return m_PathA; };
	 bool							IsDirty() const { return m_IsDirty; };
	 void							Reset();

protected:

	Tile*							FindSmallestCostTile();
	bool							IsXYWithinGrid(int Y, int X);
	bool							SearchIndexInList(std::vector<Tile*>& VList, Tile* TileSearch, int& SearchIndex);
	


	int								m_ScoreTarget;
	float							m_ScoreShow;
	float							m_Diff;
	


	int								m_Cols;
	int								m_Rows;
	std::vector<Tile*>				m_OpenList;	
	std::vector<Tile*>				m_CloseList;
	std::vector<Tile*>				m_PathA;
	bool							m_IsFound;
	
	
	Tile							m_TileA[MAX_COUNT_Y][MAX_COUNT_X];

	int								m_LastStartX;
	int								m_LastStartY;
	int								m_LastEndX;
	int								m_LastEndY;

	bool							m_IsDirty;



};

#endif